<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="renderer" content="webkit">
<title>大连交通大学在线服务平台</title>
<link href="../css/bootstrap.min.css" rel="stylesheet" />
<link href="../css/font-awesome.min.css" rel="stylesheet" />
<link href="../css/common.css" rel="stylesheet" />
<link href="../images/favicon.ico" rel="shortcut icon" />
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.js"></script>
<script src="../js/bootstrapValidator.min.js"></script>
<script src="../js/language/zh_CN.js"></script>
<script src="../admin/kindeditor/kindeditor.js"></script>
<script src="../admin/kindeditor/lang/zh_CN.js"></script>
<script src="../js/common.js"></script>
<script type="text/javascript">
	KindEditor.ready(function(K) {
		var options = {
			cssPath : getRootPath() + '/admin/kindeditor/themes/default/default.css',
			items : [ 'bold', 'italic', 'underline', 'removeformat', '|', 'forecolor', 'hilitecolor', 'fontname',
					'fontsize', '|', 'link', 'unlink', 'emoticons', 'quote', '|', 'source', 'about' ],
			uploadJson : getRootPath() + '/admin/kindeditor/jsp/upload_json.jsp',
			allowImageUpload : false,
			urlType : 'absolute'
		};
		window.editor = K.create('#reply_editor', options);
	});
	goods_showLoginDlg = function() {
		window.parent.showLoginDlg();
	}
	function deleteMessage(mid) {
		var r = confirm("您确定要删除这条回复么？")
		if (r == true) {
			window.location.href = "message_i_delete.do?mid=" + mid;
		}
	}
</script>
</head>
<body>
	<div class="center-block-2">
		<div class="list-group">
			<p class="list-group-item active">
				<img src="../images/ershou.png" width="20px" height="20px" alt="" /> 商品细节：
			</p>

			<div class="goods-detail">
				<table>
					<tr>
						<td><img src="../${goodsdetail.imgurl}" alt="${goodsdetail.name}"></td>
						<td width="470px">
							<table class="goods-detail-right">
								<tr>
									<td colspan="2">${goodsdetail.name}</td>
									<td></td>
								</tr>
								<tr>
									<td><p class="price glyphicon glyphicon-yen">${goodsdetail.price}</p></td>
								</tr>
								<tr>
									<td>卖家:</td>
									<td>${goodsdetail.realname}</td>
								</tr>
								<tr>
									<td>浏览次数：</td>
									<td>${goodsdetail.hitcount}</td>
								</tr>
								<tr>
									<td>新旧程度：</td>
									<td><c:forEach items="${application.good_level}" var="good_level" begin="0" end="9">
											<c:if test="${good_level.optcode == goodsdetail.level}">${good_level.optname}</c:if>
										</c:forEach></td>
								</tr>
								<tr>
									<td>联系电话：</td>
									<td>${goodsdetail.phone}</td>
								</tr>
								<tr>
									<td>Email：</td>
									<td>${goodsdetail.email}</td>
								</tr>
								<tr>
									<td>货物地址：</td>
									<td><c:forEach items="${application.location}" var="location" begin="0" end="9">
											<c:if test="${location.optcode == goodsdetail.location}">${location.optname}</c:if>
										</c:forEach></td>
								</tr>
							</table>
						</td>
					</tr>
				</table>
				<br>
				<p style="word-break: break-all">详细介绍：${goodsdetail.detail}</p>
			</div>
		</div>
		<div class="list-group">
			<p class="list-group-item active">
				<img src="../images/ershou.png" width="20px" height="20px" alt="" /> 评论：
			</p>
			<c:choose>
				<c:when test="${not empty msgdetail}">
					<c:forEach items="${msgdetail}" var="message" begin="0" end="5">
						<p>
							用户:${message.realname}<span style="float: right;"><fmt:formatDate value="${message.createtime}"
									pattern="yyyy.MM.dd HH:MM:ss" /> <c:if test="${message.realname == user.realname}">
									<a href="javascript:deleteMessage(${message.mid})">删除</a>
								</c:if></span>
						</p>
						<pre>${message.content}</pre>
					</c:forEach>
				</c:when>
				<c:otherwise>
					<h2>商品暂时无评论，喜欢就留下足迹。</h2>
				</c:otherwise>
			</c:choose>
		</div>

		<c:choose>
			<c:when test="${not empty user}">
				<form action="message_i_add.do" method="post">
					<input type="hidden" name="gid" value="${goodsdetail.gid}" /> <input type="hidden" name="uid"
						value="${user.uid}" /> <input type="hidden" name="realname" value="${user.realname}" />
					<textarea id="reply_editor" name="content" style="height: 110px; width: 450px;"></textarea>
					<button type="submit" class="btn btn-success btn-sm">添加评论</button>
				</form>
			</c:when>
			<c:otherwise>
				<center>
					<button type="button" data-toggle="modal" onclick="goods_showLoginDlg()" class="btn btn-success btn-lg">评论请先登录</button>
				</center>
			</c:otherwise>
		</c:choose>
	</div>
</body>
</html>